import request from '@/utils/request'

// 查询生产物料信息列表
export function listMateriel(query) {
  return request({
    url: '/project/materiel/list',
    method: 'get',
    params: query,
  })
}

// 查询物料品质标准
export function listMaterielQuality(query) {
  return request({
    url: '/project/materiel/qualityList',
    method: 'get',
    params: query,
  })
}

// 查询生产物料信息列表
export function listMinPackage(query) {
  return request({
    url: '/project/materiel/listMinPackage',
    method: 'get',
    params: query,
  })
}
// 查询生产物料信息详细
export function getMateriel(itmId) {
  return request({
    url: '/project/materiel/' + itmId,
    method: 'get',
  })
}

// 新增生产物料信息
export function addMateriel(data) {
  return request({
    url: '/project/materiel',
    method: 'post',
    data: data,
  })
}

// 修改生产物料信息
export function updateMateriel(data) {
  return request({
    url: '/project/materiel',
    method: 'put',
    data: data,
  })
}

// 修改生产物料信息 某项值
export function updateitmMinbz(data) {
  return request({
    url: '/project/materiel/updateMinzb',
    method: 'put',
    data: data,
  })
}

// 删除生产物料信息
export function delMateriel(itmId) {
  return request({
    url: '/project/materiel/' + itmId,
    method: 'delete',
  })
}

// 导出生产物料信息
export function exportMateriel(query) {
  return request({
    url: '/project/materiel/export',
    method: 'get',
    params: query,
  })
}
//导出最小包装
export function exportItmMinbz(query) {
  return request({
    url: '/project/materiel/exportItmMinbz',
    method: 'get',
    params: query,
  })
}

//获取大分类信息
export function getFirstChild(data) {
  return request({
    url: '/project/lbm/getFirstChild/' + data,
    method: 'get',
  })
}

//生成物料代码
export function generateItemCode(data) {
  return request({
    url: '/project/materiel/generateItemCode/' + data,
    method: 'get',
  })
}

//获取仓位信息
export function getStorage(data) {
  return request({
    url: '/project/materiel/getStorage/' + data,
    method: 'get',
  })
}
//变更周期
export function changeStorage(itmId, itmTedzq) {
  return request({
    url: '/project/materiel/editCycle/' + itmId + '/' + itmTedzq,
    method: 'put',
  })
}

//根据 物料代码 或者 客户编码 查询信息
export function selectItmByWldm(wldm) {
  return request({
    url: '/project/materiel/selectItmByWldm/' + wldm,
    method: 'get',
  })
}

//根据 物料代码 或者 客户编码 查询信息
export function getItmMstrByCustwldm(somCustwldm) {
  return request({
    url: '/project/materiel/selectItmByCustwldm/' + somCustwldm,
    method: 'get',
  })
}

//将供应商与物料进行绑定
export function bindCsm(data) {
  return request({
    url: '/project/itcsl',
    method: 'post',
    data: data,
  })
}

//修改物料绑定的厂商
export function updateCsm(data) {
  return request({
    url: '/project/itcsl',
    method: 'put',
    data: data,
  })
}

// 修改厂商资料
export function updateItcs(data) {
  return request({
    url: '/project/itcsl/updateItcs',
    method: 'put',
    data: data
  })
}

//删除物料绑定的厂商
export function deleteCsm(query) {
  return request({
    url: '/project/itcsl/' + query,
    method: 'delete',
  })
}

//按照物料查询厂商代码
export function getCsmByWldm(query) {
  return request({
    url: '/project/itcsl/getCsmByItmWldm/' + query,
    method: 'get',
  })
}
/** 客户编码字典 */
export function cusWldmDict() {
  return request({
    url: '/project/materiel/cusWldmDict',
    method: 'get',
  })
}
/** 根据物料代码 获取图片路径 */
export function getImageByWldm(wldm) {
  return request({
    url: '/project/materiel/getImageByWldm/' + wldm,
    method: 'get',
  })
}
/** 物料代码下拉列表 */
export function getItmWldmList() {
  return request({
    url: '/project/materiel/getItmWldmList',
    method: 'get',
  })
}

/**   客户编码 + 物料编码  下拉列表 */
export function getItmWldmAndCustWldmList() {
  return request({
    url: '/project/materiel/getItmWldmAndCustWldmList',
    method: 'get',
  })
}

/** 客户编码 + 物料编码 查询框 */
export function getItmMstrByItmWldmOrCustWldm(query, form) {
  return request({
    url: '/project/materiel/getItmMstrByItmWldmOrCustWldm/' + query,
    method: 'get',
    params: form,
  })
}

/** 物料信息列表 */
export function getItmByInfo(params) {
  return request({
    url: '/project/materiel/getItmByInfo',
    method: 'get',
    params,
  })
}

export function getItmRelevanceCs(itmWldm) {
  return request({
    url: '/project/materiel/getItmRelevanceCs/' + itmWldm,
    method: 'get'
  })
}

/**
 * 
 * @param {*} data 
 * @returns 修改制造车间
 */
export function updateWorkShop(data) {
  return request({
    url: '/project/materiel/editItmCj',
    method: 'put',
    data: data
  })
}